﻿using Mes.Application.DTO.Inputs.WorkOrders;
using Mes.Application.DTO.Results.WorkOrders;
using Mes.Domain.BoundedContext;

namespace Mes.Application.Services.WorkOrders
{
    public interface IWoFlowService
    {
        /// <summary>
        /// 增加生产
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task AddItemProdAsync(AddingItemProdInput input);

        /// <summary>
        /// 减少生产
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task ReduceItemProdAsync(ReducingItemProdInput input);

        /// <summary>
        /// 查询作业队列
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<ItemsResult<EntJobsResult>> GetEntJobsAsync(GettingEntJobsInput input);

        /// <summary>
        /// 查询正在运行的job的产量列表、物料清单、工步列表数据集
        /// </summary>
        /// <param name="wo_Id">工单编号</param>
        /// <param name="oper_Id">操作编号</param>
        /// <returns></returns>
        Task<RunningJobProdBOMStepResult> GetRunningJobProdsBOMsStepsAsync(string wo_Id, string oper_Id);

        /// <summary>
        /// 添加消耗量
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task AddItemConsAsync(AddingItemConsInput input);

        /// <summary>
        /// 启动工步（工步状态由Ready->Running）
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task StartJobStepAsync(StartingJobStepInput input);

        /// <summary>
        /// 停止工步（工步状态由Running->Complete或者工步状态由Complete->SUPERSEDED,或者SUPERSEDED->Complete）
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task StopJobStepAsync(StoppingJobStepInput input);

        /// <summary>
        /// 查询存在job的实体列表
        /// </summary>
        /// <returns></returns>
        Task<ItemsResult<IdNameResult>> GetEntitiesWithJobsAsync();

        /// <summary>
        /// 作业-准备生产
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task ReadyJobAsync(ReadyingJobInput input);

        /// <summary>
        /// 作业-运行所选作业
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task RunJobAsync(RunningJobInput input);

        /// <summary>
        /// 作业-暂停
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task PauseJobAsync(PausingJobInput input);

        /// <summary>
        /// 作业-完成
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task EndJobAsync(EndingJobInput input);
    }
}
